package confidence.helpers;


import java.util.Calendar;
import java.util.Date;

public class Tag {
	public Vector3 coordRef = null, coordBody = null, vRef = null;
	protected Vector3 coordBodyF = null, vBody = null, vBodyF = null;
	
	protected Vector3 coordBodyFNano = null, vBodyNano = null, vBodyFNano = null;

	public Date date;
	public Calendar time;
	public int minute;
	public int second;
	public String tagClass;
	public String pClass;
	private Boolean isMoving = null;

	private double sumDifference;
	private double minMax;
	
	
	/** Log changes caused by filters. */
	public String filterHistroy = "";
	private String label;

	/**Because there are 2 types of messages coming in
	 *  If the message is inertion than inertion is true
	 * */
	public String type = null;
	public Vector3 vRefUbi;
	
	public Tag () {
	}

	/**
	 * Constructor sets reference coordinate system.
	 * @param coord
	 */
	public Tag (Vector3 coord) 
	{
		coordRef = coord;
	}
	
	
	public Tag (Date dateN, double pX, double pY, double pZ) {

		coordRef = new Vector3 (pX, pY, pZ);
		date=dateN;
		time = Calendar.getInstance();
		time.setTime(dateN);
	}
	
	
	
	public Tag(Date dateN, double pX, double pY, double pZ, String label, String pClass) 
	{
		coordRef =  new Vector3 (pX, pY, pZ);
		date=dateN;
		time = Calendar.getInstance();
		time.setTime(dateN);
		this.label = label;
		this.pClass = pClass;
		//this.tagClass = tagClass;
	}

	
	public String toString () {
		String result = "";
		
		if (coordRef != null) {
			result += "ref " + coordRef;
			if (coordBody != null) {
				result += " body " + coordBody;
			}
		}
		
		
			
		return result;
	}
	
	public Tag clone(){
		Tag tag=new Tag();
		Vector3 coordRefNew=null;
		if(coordRef!=null)
		{
			coordRefNew=new Vector3(coordRef.x+0.0, coordRef.y+0.0, coordRef.z+0.0);
		}
		
		Vector3 coordBodyNew=null;
		if(coordBody!=null)
		{
			coordBodyNew=new Vector3(coordBody.x+0.0, coordBody.y+0.0, coordBody.z+0.0);
		}
		
		Vector3 vRefNew=null;
		if(vRef!=null)
		{
			vRefNew=new Vector3(vRef.x+0.0, vRef.y+0.0, vRef.z+0.0);
		}
		
		Vector3 coordBodyFNew=null;
		if(coordBodyF!=null)
		{
			coordBodyFNew=new Vector3(coordBodyF.x+0.0, coordBodyF.y+0.0, coordBodyF.z+0.0);
		}
		
		Vector3 vBodyNew=null;
		if(vBody!=null)
		{
			vBodyNew=new Vector3(vBody.x+0.0, vBody.y+0.0, vBody.z+0.0);
		}
		
		Vector3 vBodyFNew=null;
		if(vBodyF!=null)
		{
			vBodyFNew=new Vector3(vBodyF.x+0.0, vBodyF.y+0.0, vBodyF.z+0.0);
		}
		
		Vector3 coordBodyFNanoNew=null;
		if(coordBodyFNano!=null)
		{
			coordBodyFNanoNew=new Vector3(coordBodyFNano.x+0.0, coordBodyFNano.y+0.0, coordBodyFNano.z+0.0);
		}
		
		Vector3 vBodyNanoNew=null;
		if(vBodyNano!=null)
		{
			vBodyNanoNew=new Vector3(vBodyNano.x+0.0, vBodyNano.y+0.0, vBodyNano.z+0.0);
		}
		
		Vector3 vBodyFNanoNew=null;
		if(vBodyFNano!=null)
		{
			vBodyFNanoNew=new Vector3(vBodyFNano.x+0.0, vBodyFNano.y+0.0, vBodyFNano.z+0.0);
		}

		
		String tagClassNew=tagClass+"";

		String pClassNew = pClass;
		String filterHistroyNew = this.filterHistroy+"";
		String labelNew=label+"";

		String typeNew = type+"";
		
		Vector3 vRefUbiNew=null;
		if(vRefUbi!=null)
		{
			vRefUbiNew=new Vector3(vRefUbi.x+0.0, vRefUbi.y+0.0, vRefUbi.z+0.0);
		}
		
		
		
		tag.coordRef=coordRefNew;
		tag.coordBody=coordBodyNew;
		tag.vRef=vRefNew;
		tag.coordBodyF=coordBodyFNew;
		tag.vBody=vBodyNew;
		tag.vBodyF=vBodyFNew;
		tag.coordBodyFNano=coordBodyFNanoNew;
		tag.vBodyNano=vBodyNanoNew;
		tag.vBodyFNano=vBodyFNanoNew;
		tag.tagClass=tagClassNew;
		tag.pClass = pClassNew;
		tag.filterHistroy=filterHistroyNew;
		tag.label=labelNew;
		tag.type=typeNew;
		tag.vRefUbi=vRefUbiNew;
	
		
		
		
		return tag;
	}

	

	public double getSumDifference() {
		return sumDifference;
	}

	public void setSumDifference(double sumDifference) {
		this.sumDifference = sumDifference;
	}

	public double getMinMax() {
		return minMax;
	}

	public void setMinMax(double minMax) {
		this.minMax = minMax;
	}
	
	
	

}
